<template>
	<view class="">
		<view class="img">
			<image src="../../static/image 24.png" mode=""></image>
		</view>
		<view class="but-two" @tap="getlogin">
			<text>微信登录</text>
		</view>
		<view class="but-three" @tap="phone">
			<text>手机登录</text>
		</view>
		<view class="but-four" @tap="retur">
			<text>返回</text>
		</view>
	
		<view class="but-five">
			<text>温馨提示：未注册「卤制深」的用户，初次登录时将完成注册</text>
		</view>
	</view>
</template>

<script>
	// import {toLogin} from '@/api/login.js'
	import {setToken} from "@/common/token.js"
	import {
		getLogin
	} from "@/api/home.js"
	export default {
		data() {
			return {
				code:"",
			}
		},
		methods: {
			phone() {
				uni.navigateTo({
					url: '/pages/PhoneLogin/PhoneLogin'
				})
			},
			retur() {
				uni.navigateBack({
					url: '/pages/index/index'
				})
			},
			// dddddd(){
			// 	uni.login({
			// 		success(res) {
			// 			console.log("搜索",res);
			// 		}
			// 	})
			// },
			getlogin() {
				uni.login({
					provider: 'weixin',
					onlyAuthorize: true,
					success: (loginRes) => {
						this.code = loginRes.code
						console.log(loginRes);
						
					},
				})
				uni.getUserProfile({
					desc:"weixin",
					success:(res)=>{
						console.log(res);
						getLogin({
							code:this.code,
							iv:res.iv,
							encryptedData:res.encryptedData
						}).then(res=>{
							console.log(res);
							if(res.code = 200){
								setToken("token",res.token)
							}
						})
					},
					
				})
				
				uni.navigateTo({
					url:"/pages/AddressTime/AddressTime"
				})
			},
			
			
		}
	}
</script>

<style lang="scss" scoped>
	.img {
		width: 436rpx;
		height: 436rpx;

		image {
			width: 436rpx;
			height: 436rpx;
			margin-top: 112rpx;
			margin-left: 156rpx;
		}
	}

	.but-two {
		width: 562rpx;
		height: 96rpx;
		background: #FB7A42;
		border-radius: 48rpx;
		margin-top: 120rpx;
		margin-left: 94rpx;

		text {
			display: block;
			width: 128rpx;
			height: 32rpx;
			font-family: 'PingFang SC';
			font-style: normal;
			font-weight: 400;
			font-size: 32rpx;
			line-height: 80rpx;
			text-align: center;
			color: #FFFFFF;
			margin-left: 216rpx;

		}
	}

	.but-three {
		width: 562rpx;
		height: 96rpx;
		margin-top: 20rpx;
		margin-left: 94rpx;

		text {
			display: block;
			width: 128rpx;
			height: 32rpx;
			font-family: 'PingFang SC';
			font-style: normal;
			font-weight: 400;
			font-size: 32rpx;
			line-height: 80rpx;
			text-align: center;
			color: #FB7A42;
			margin-left: 216rpx;

		}
	}

	.but-four {
		width: 562rpx;
		height: 96rpx;
		margin-top: 10rpx;
		margin-left: 94rpx;

		text {
			display: block;
			width: 56rpx;
			height: 28rpx;
			font-family: 'PingFang SC';
			font-style: normal;
			font-weight: 400;
			font-size: 28rpx;
			line-height: 28rpx;
			text-align: center;
			color: #8C8C8C;
			margin-left: 240rpx;

		}
	}

	.but-five {
		width: 900rpx;
		height: 96rpx;
		margin-bottom: 0rpx;

		text {
			display: block;
			width: 900rpx;
			height: 24rpx;
			font-family: 'PingFang SC';
			font-style: normal;
			font-weight: 400;
			font-size: 24rpx;
			line-height: 24rpx;
			text-align: center;
			color: #8C8C8C;
			margin-top: 250rpx;
			margin-left: -72rpx;

		}
	}
</style>
